 require 'json'
 def load_properties(properties_filename)
         properties = {}
         File.open(properties_filename, 'r') do |properties_file|
           properties_file.read.each_line do |line|
             line.strip!
             if (line[0] != ?# and line[0] != ?=)
               i = line.index('=')
               if (i)
                properties[line[0..i - 1].strip] = line[i + 1..-1].strip
              else
                properties[line] = ''
              end
            end
          end      
        end
        properties
end
class Version
  attr_reader :version,:date,:message
  attr_writer :version,:date,:message
  def to_json(*args)
      {
        'version'  =>@version,
        'date'     =>@date,
        'message'  =>@message
      }.to_json(*args)
    end
end
class VersionController < ApplicationController
  include JSON
  def index
    propertiy = load_properties("/usr/local/bnet/taokuaidi/download/version.properties")
    version = Version.new
    version.version=propertiy["version"]
    version.date=propertiy["date"]
    version.message=propertiy["message"]
    render :text=>generate(version)
  end
end

